diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc
index 0112285fb9..07aad9eb80 100644
--- a/src/compiler/cpp_generator.cc
+++ b/src/compiler/cpp_generator.cc
@@ -97,6 +97,7 @@ std::string GetHeaderPrologue(grpc_generator::File* file,
                                      ? kCppGeneratorMessageHeaderExt
                                      : params.message_header_extension;
 
+    printer->Print(vars, "#pragma once\n");
     printer->Print(vars, "// Generated by the gRPC C++ plugin.\n");
     printer->Print(vars,
                    "// If you make any local change, they will be lost.\n");
@@ -2153,6 +2154,7 @@ std::string GetMockPrologue(grpc_generator::File* file,
                                      : params.message_header_extension;
     vars["service_header_ext"] = kCppGeneratorServiceHeaderExt;
 
+    printer->Print(vars, "#pragma once\n");
     printer->Print(vars, "// Generated by the gRPC C++ plugin.\n");
     printer->Print(vars,
                    "// If you make any local change, they will be lost.\n");
